package com.chinaunicom.emergency.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class ConfigUtil implements ApplicationContextAware
{

    private static ApplicationContext applicationContext = null;

    public static String get(String key) {
        String value = "";
        try {
            value = applicationContext.getEnvironment().getProperty(key);
        }catch (Exception e){
            e.printStackTrace();
        }
        return value;
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        if(ConfigUtil.applicationContext == null){
            ConfigUtil.applicationContext  = applicationContext;
        }
    }
}
